package fission;

import fission.FissionGame;
import fission.FissionMove;
import fission.FissionPlayer;

/**
 *
 * @author MichaelAlbert
 */
public class RandomPlayer extends FissionPlayer {
    
    static final String[] COMMENTS = {
        "What, me random?",
        "Who are you calling random?",
        "Random roolz!",
        "I'll take a chance",
        "Heads I win",
        "Tails you lose",
        "The capital of Kansas is Topeka"
    };
    
    public RandomPlayer(String name, boolean moveType) {
        super(name, moveType);
    }

    @Override
    public void generateMove(FissionGame g) throws InterruptedException {
        int possibleMoves = 0;
        FissionMove result = null;
        for(int r = 0; r < g.getRows(); r++) {
            for(int c = 0; c < g.getColumns(); c++) {
                FissionMove m = new FissionMove(r, c, getType());
                if (g.isValidMove(m)) {
                    possibleMoves++;
                    if (Math.random()*possibleMoves < 1.0) {
                        result = m;
                    }
                }
            }
        }
//        int x = 20;
//        while (x != 0) { x = 4*5;}
        move = result;
        throw new InterruptedException();
    }
    
    @Override
    public String makeComment() {
        return COMMENTS[(int) (Math.random()*COMMENTS.length)];
    }
    
    @Override
    public int getEvaluation() {
        return (int) (Math.random()*2001 - 1000);
    }
}
